<template>
	<view class="fac bgw br8 px6 py3">
		<u-icon name="search" color="#999" size="40" @click="navto('item/search')" />
		<input class="f1" placeholder="请输入商品名称,体验店名称" placeholder-class="c11 pl3" @click="navto('item/search')" :disabled="true" />
		<u-icon name="scan" color="#999" size="40" @click="scan" />
	</view>
</template>

<script>
import util from '@/utils/util'

export default {
	props: {
		placeholder: {
			type: String,
			default: '暂无内容哦~'
		},
		bg: {
			type: String,
			default: 'px4'
		}
	},
	data(){
		return {
			visible: false,
			showHot: true,
			searchName: '取消',
			isDelShow: false,
			keyword: '',
			hotList: [],
			historyList: uni.getStorageSync('searchHistory') || [],
			// #ifdef APP-PLUS
			statusBarHeight: uni.getSystemInfoSync().statusBarHeight + 'px'
			// #endif
			// #ifndef APP-PLUS
			statusBarHeight: 0
			// #endif
		}
	},
	props: {
		path: {
			value: String,
			default: 'vedio/index'
		},
		placeholder:{
			value: String,
			default: '请输入搜索内容'
		},
		name: {
			value: String,
			default: 'title'
		},
		radius: {
			value: [String, Number],
			default: 60
		}
	},
	methods: {
		clear() {
			//HM修改 收起键盘
			uni.hideKeyboard();
			//HM修改 清空内容时候触发组件input
			this.$emit('update:value', '');
		},
		//执行搜索
		async search() {
			let historyList = uni.getStorageSync('SearchHistory');
			if (typeof(historyList) === 'object') {
				!historyList.includes(this.keyword) && historyList.push(this.keyword)	
			} else {
				historyList = []
			}
			uni.setStorageSync('SearchHistory', historyList)
			util.navto(this.path + '?' + this.name + '='+ this.keyword)
		}
	},
	watch: {
		keyword(newVal) {
			if (newVal) {
				this.searchName = '搜索';
			} else {
				this.searchName = '取消';
				this.isDelShow = false;
			}
		},
	}
};
</script>

<style lang="scss">
</style>
